const formatDateOnUnitsDigit = (number) => number < 10 ? `0${number}` : number

export function formatDate(timestamp) {
    const date = new Date(timestamp)
    const year = date.getFullYear()
    const month = formatDateOnUnitsDigit(date.getMonth() + 1)
    const day = formatDateOnUnitsDigit(date.getDate())
    const hour = formatDateOnUnitsDigit(date.getHours())
    const min = formatDateOnUnitsDigit(date.getMinutes())
    const secounds = formatDateOnUnitsDigit(date.getUTCSeconds())

    const getDate = () => `${year}年${month}月${day}日`
    const getTime = () => `${hour}:${min}:${secounds}`

    return {
        year, month, day, hour, min, secounds, getDate, getTime
    }
}